package com.aiju.cash.core.api;

import android.text.TextUtils;

import com.aiju.app.callback.HttpCallback;
import com.aiju.common.http.interceptor.HttpFactory;
import com.aiju.widgit.dialog.DialogHelper;

import java.util.HashMap;
import java.util.Map;

import static com.aiju.app.config.ConfigManager.INIT_SERVER_HOST;

/**
 * @author: 佐为
 * @date: 2017-05-31 10:57
 * @version: V1.0
 * @Description: 描述
 */
public class EnterApi extends BaseApi {
    private String getArea = INIT_SERVER_HOST + "/reputation/getArea";
    private String getCategory = INIT_SERVER_HOST + "/reputation/getCategory";
    private String getShopInfoByStoreId = INIT_SERVER_HOST + "/reputation/getShopInfoByStoreId";
    private String getImageInfo = INIT_SERVER_HOST + "/reputation/getImageInfo";
    private String deleteImageInfo = INIT_SERVER_HOST + "/reputation/deleteImageInfo";
    private String createAndUpdateShop = INIT_SERVER_HOST + "/reputation/createAndUpdateShop";

    private HttpFactory instance;

    public EnterApi(DialogHelper dialogHelper) {
        super(dialogHelper);
        instance = HttpFactory.getInstance();
        instance.setDialogHelper(dialogHelper);
    }

    public void setDialogHelper(DialogHelper dialogHelper) {
        instance.setDialogHelper(dialogHelper);
    }

    /**
     * 店铺添加接口
     *
     * @param callback
     */
    public void createAndUpdateShop(String id, String store_id, String shop_type, String category_id, String brand_name, String brand_logo,
                                    String main_shop_name, String branch_shop_name, String province_code,
                                    String city_code, String district_code, String address, String code_name, String category_name,
                                    String longitude, String latitude, String contact_number,
                                    String main_image, String audit_images,
                                    String wifi, String parking, String avg_price, String licence,
                                    String licence_code, String licence_name, String business_certificate,
                                    String business_certificate_expires, String auth_letter,
                                    String no_smoking, String box, String other_authorization, String licence_expires,
                                    HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        if (!TextUtils.isEmpty(id)) {
            map.put("id", id);
        }
        if (!TextUtils.isEmpty(store_id)) {
            map.put("store_id", store_id);
        }
        map.put("parent_store_id", mUser.getParentStoreId());
        map.put("shop_type", shop_type);
        map.put("category_id", category_id);
        map.put("brand_name", brand_name);
        map.put("brand_logo", brand_logo);
        map.put("main_shop_name", main_shop_name);
        map.put("branch_shop_name", branch_shop_name);
        map.put("province_code", province_code);
        map.put("city_code", city_code);
        map.put("district_code", district_code);
        map.put("address", address);
        map.put("code_name", code_name);
        map.put("category_name", category_name);
        map.put("longitude", longitude);
        map.put("latitude", latitude);
        map.put("contact_number", contact_number);
        map.put("notify_mobile", mUser.getPhone());
        map.put("main_image", main_image);
        map.put("audit_images", audit_images);
        map.put("business_time", "");
        map.put("wifi", wifi);
        map.put("parking", parking);
        map.put("value_added", "");
        map.put("avg_price", avg_price);
        map.put("licence", licence);
        map.put("licence_code", licence_code);
        map.put("licence_name", licence_name);
        map.put("business_certificate", business_certificate);
        map.put("business_certificate_expires", business_certificate_expires);
        map.put("auth_letter", auth_letter);
        map.put("is_operating_online", "");
        map.put("online_url", "");
        map.put("implement_id", "");
        map.put("no_smoking", no_smoking);
        map.put("box", box);
        map.put("other_authorization", other_authorization);
        map.put("licence_expires", licence_expires);
        instance.makeProxy().requestPost(createAndUpdateShop, map, callback);
    }

    /**
     * 获取地区
     *
     * @param callback
     */
    public void getArea(HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(getArea, map, callback);
    }

    /**
     * 获取类别
     *
     * @param callback
     */
    public void getCategory(HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(getCategory, map, callback);
    }

    /**
     * 获取口碑店铺信息接口
     *
     * @param callback
     */
    public void getShopInfoByStoreId(String storeId, HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("storeId", storeId);
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(getShopInfoByStoreId, map, callback);
    }

    /**
     * 获取图片信息接口
     *
     * @param callback
     */
    public void getImageInfo(String reputation_image_id, HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("reputation_image_id", reputation_image_id);
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(getImageInfo, map, callback);
    }

    /**
     * 删除图片信息接口
     *
     * @param callback
     */
    public void deleteImageInfo(String reputation_image_id, HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("reputation_image_id", reputation_image_id);
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(deleteImageInfo, map, callback);
    }


}
